package com.xiao.hao.controller;


import com.xiao.hao.config.CheckParamsAnnotation;
import com.xiao.hao.constant.CheckParamsEnum;
import com.xiao.hao.facade.XhAllConfigFacade;
import com.xiao.hao.facade.XhProductFacade;
import com.xiao.hao.facade.XhProductUserFacade;
import com.xiao.hao.facade.XhUserInfoFacade;
import com.xiao.hao.req.XhAskAboutInsertReq;
import com.xiao.hao.req.XhUserInfoGetCodeReq;
import com.xiao.hao.req.XhUserInfoLoginReq;
import com.xiao.hao.resp.BcSelectResp;
import com.xiao.hao.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Description 用户表 controller层
 * @Author xiaohao
 * @Date 2025-03-01 10:58:34
 */

@Api(tags = "用户表控制层")
@RestController
@Slf4j
@RequestMapping("xhUserInfo")
public class XhUserInfoController {


    @Resource
    private XhUserInfoFacade facade;


    @Resource
    private XhProductFacade xhProductFacade;


    @Resource
    private XhAllConfigFacade xhAllConfigFacade;

    @Resource
    private XhProductUserFacade xhProductUserFacade;

    @ApiOperation(value = "查询产品列表")
    @PostMapping("queryProduct")
    public Result queryProduct() {
        return xhProductFacade.queryProduct();
    }


    /**
     * 文件上传
     *
     * @param file
     * @return
     */
    @PostMapping("/upload")
    @ApiOperation("文件上传")
    public Result upload(MultipartFile file) {
        return facade.upload(file);
    }


    @ApiOperation(value = "用户登录或注册")
    @PostMapping("login")
    @CheckParamsAnnotation(CheckParamsEnum.INSERT_CHECK)
    public Result insert(@RequestBody XhUserInfoLoginReq req) {
        return facade.insert(req);
    }

    @ApiOperation(value = "获取短信验证码")
    @PostMapping("getLoginCode")
    @CheckParamsAnnotation(CheckParamsEnum.COMMON_CHECK)
    public Result getLoginCode(@RequestBody XhUserInfoGetCodeReq req) {
        return facade.getLoginCode(req);
    }

    @ApiOperation(value = "退出接口")
    @PostMapping("outLogin")
    public Result outLogin() {
        return facade.outLogin();
    }

    @ApiOperation(value = "获取用户信息")
    @PostMapping("getUserInfo")
    public Result getUserInfo() {
        return facade.getUserInfo();
    }

    @ApiOperation(value = "全局枚举接口获取")
    @PostMapping("getCommnEnums")
    public Result<BcSelectResp> getCommnEnums() {
        return facade.getCommnEnums();
    }

//    @ApiOperation(value = "询问问题")
//    @PostMapping("gerQuery")
//    public Result gerQuery(@RequestBody XhAskAboutInsertReq req) {
//        return facade.gerQuery(req);
//    }

    @ApiOperation(value = "询问问题")
    @PostMapping("gerQuery")
    public Result gerQueryNew(@RequestBody XhAskAboutInsertReq req) {
        return facade.gerQueryNew(req);
    }

    @ApiOperation(value = "查询全部产品目录查询")
    @PostMapping("queryProductAll")
    public Result queryProductAll() {
        return xhProductUserFacade.queryProductAll();
    }


//    @ApiOperation(value = "修改保存用户信息")
//    @PostMapping("update")
//    @CheckParamsAnnotation(CheckParamsEnum.UPDATE_CHECK)
//    public Result update(@RequestBody XhUserInfoUpdateReq req) {
//        return facade.update(req);
//    }

//    @PostMapping("delete")
//    @ApiOperation(value = "删除")
//    public Result delete(@RequestBody BaseId req) {
//        return facade.delete(req);
//    }

//    @ApiOperation(value = "分页查询")
//    @PostMapping("queryPage")
//    public PageResult queryPage(@RequestBody XhUserInfoQueryPageReq req) {
//        return facade.queryPage(req);
//    }

    @ApiOperation(value = "第二次询问问题")
    @PostMapping("staticQuery")
    public Result staticQuery(@RequestBody XhAskAboutInsertReq req) {
        return Result.succeed("接入DeepSeek API调整中。。。。");
    }


    @ApiOperation(value = "全局配置接口")
    @PostMapping("configSwitch")
    public Result configSwitch() {
        return xhAllConfigFacade.configSwitch();
    }

}


